{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append('../')\n",
    "\n",
    "import noaa_datasets\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Success!\n",
      "Retrieving USW00014942.dly\n",
      "Transposing USW00014942 dataset\n",
      "Applying data prep operations\n",
      "Success!\n",
      "Creating epply_snow dataset\n",
      "Success!\n"
     ]
    }
   ],
   "source": [
    "# create epply_snow dataset\n",
    "stations = noaa_datasets.Stations()\n",
    "epply = noaa_datasets.DailyFile('USW00014942')\n",
    "print('Creating epply_snow dataset')\n",
    "epply.df = epply.df[ epply.df['ELEMENT']=='SNOW' ]\n",
    "epply.df = epply.df[ epply.df['VALUE']>0 ]\n",
    "epply.df['Snow (inches)'] = epply.df.apply(epply.mm_to_inches, axis=1)\n",
    "epply.df['Season'] = epply.df.apply(epply.winter_season, axis=1)\n",
    "epply.df.sort_values(by='Snow (inches)', ascending=False)\n",
    "epply.df = pd.merge(epply.df, stations.df, right_index=True, left_on='StationID')\n",
    "epply.df.sort_values(by=['YEAR', 'MONTH'], inplace=True)\n",
    "epply.df.to_csv('../data/epply_snow.csv', sep='\\t')\n",
    "print('Success!')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
